<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- androiddev.qdoc -->
  <title>Connecting Android Devices | Qt Creator Manual</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qt Creator Manual</a></td><td >Connecting Android Devices</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="index.html">Qt Creator Manual 4.11.1</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="creator-connecting-mobile.html" />
  <link rel="next" href="creator-developing-baremetal.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="creator-connecting-mobile.html">Connecting Devices</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="creator-developing-baremetal.html">Connecting Bare Metal Devices</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#requirements">Requirements</a></li>
<li class="level1"><a href="#setting-up-the-development-environment">Setting Up the Development Environment</a></li>
<li class="level2"><a href="#specifying-android-device-settings">Specifying Android Device Settings</a></li>
<li class="level2"><a href="#managing-android-sdk-packages">Managing Android SDK Packages</a></li>
<li class="level1"><a href="#selecting-android-devices">Selecting Android Devices</a></li>
<li class="level1"><a href="#using-the-android-emulator">Using the Android Emulator</a></li>
<li class="level1"><a href="#debugging-on-android-devices">Debugging on Android Devices</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Connecting Android Devices</h1>
<span class="subtitle"></span>
<!-- $$$creator-developing-android.html-description -->
<div class="descr"> <a name="details"></a>
<p>You can connect Android devices to the development PC to run, debug, and analyze applications built for them from Qt Creator. Devices with Android version 4.1 (API level 16) or later are supported.</p>
<p>If you have a tool chain for building applications for Android devices installed on the development PC, you can add it to Qt Creator. You can then add a <a href="creator-glossary.html#glossary-buildandrun-kit">kit</a> with the Android device type, the tool chain, and the Qt version for Android, to build applications for and run them on Android devices. You can also allow Qt Creator to automatically configure the kit.</p>
<p>The Android Debug Bridge (adb) command line tool is integrated to Qt Creator to enable you to deploy applications to connected Android devices, to run the applications on them, and to read logs from them. It includes a client and server that run on the development host and a daemon that runs on the emulator or device.</p>
<a name="requirements"></a>
<h2 id="requirements">Requirements</h2>
<p>To use Qt Creator to develop Qt applications for Android, you need the following:</p>
<ul>
<li><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java SE Development Kit (JDK)</a> version 6, or later. You can also use <a href="http://openjdk.java.net/">OpenJDK</a> on Linux.<p><b>Note: </b>Android SDK Tools have issues with JDK versions later than 8.</p></li>
<li><a href="http://www.gradle.org">Gradle</a> for building application packages (APK) and app bundles (AAB) for Android devices. Gradle is delivered with Qt 5.9, and later. Because Gradle scripts are not delivered with Android SDK tools since version 26.0&#x2e;0, they are delivered with Qt 5.9 and 5.6&#x2e;3&#x2e;<p><b>Note: </b>Using Ant to build APKs is no longer supported.</p></li>
<li>A tool chain for building applications for Android devices provided by the <a href="http://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a> from Google.<p><b>Note: </b>To develop with Qt 5.14.0 or later, you need Android NDK r20 or later.</p></li>
<li><a href="http://developer.android.com/sdk/index.html">Android SDK Tools</a><p>The following Android SDK packages and tools are required for development:</p>
<ul>
<li>Platform tools</li>
<li>Build tools</li>
<li>At least one SDK platform</li>
</ul>
</li>
<li>On Windows, you also need the following:<ul>
<li>Android Debug Bridge (ADB) driver on the Windows platform to enable USB debugging. The default USB driver on Windows does not allow debugging. For more information about obtaining the USB driver, see <a href="http://developer.android.com/sdk/win-usb.html">http://developer.android.com/sdk/win-usb.html</a>.<p>After installing the driver, try running a few basic <a href="http://developer.android.com/tools/help/adb.html">adb</a> commands to check that your device responds to them.</p>
</li>
</ul>
<p><b>Note: </b>When using the command line tools instead of Android Studio, it is recommended to create an empty folder and extract the downloaded archive into this folder. The sdkmanager will install downloaded packages next to the <code>tools</code> folder that contains all command line tools. You must specify the path to the folder where you extracted the files as Android SDK location inside the Android settings.</p></li>
</ul>
<a name="setting-up-the-development-environment"></a>
<h2 id="setting-up-the-development-environment">Setting Up the Development Environment</h2>
<p>You must download and install the latest Android NDK and SDK, and then update or install the tools and packages needed for development. However, if your Qt version is earlier than v5.9, use the SDK tools package v25.2&#x2e;5 or earlier.</p>
<p>The SDK tool used to update and install the other SDK tools and packages depends on the Android SDK Tools version that you have installed:</p>
<ul>
<li>Android SDK Tools version 25.2&#x2e;5, or earlier<p>Use the <a href="https://developer.android.com/studio/tools/help/android.html">android</a> tool that comes with the SDK Tools package. For example, on Ubuntu the following command starts the SDK update:</p>
<pre class="cpp">

  <span class="operator">.</span><span class="operator">/</span>android update sdk

</pre>
</li>
<li>Android SDK Tools version 25.3&#x2e;0, or later<p>Use the <a href="https://developer.android.com/studio/command-line/sdkmanager.html">sdkmanager</a> command line tool for SDK package management and the <a href="https://developer.android.com/studio/command-line/avdmanager.html">avdmanager</a> tool for Android Virtual Device (AVD) management.</p>
</li>
</ul>
<p>In addition, you must install Qt for Android as part of Qt 5.2, or later.</p>
<p><b>Note: </b>You can build a 64-bit version of Qt for Android yourself. However, for such a Qt version, the minimum required Android version on devices is 5.0 (API level 21).</p><p>For more information, see <a href="http://doc.qt.io/qt-5/android.html">Qt for Android</a>.</p>
<a name="specifying-android-device-settings"></a>
<h3 id="specifying-android-device-settings">Specifying Android Device Settings</h3>
<p>To configure connections between Qt Creator and Android devices:</p>
<ol class="1" type="1"><li>Select <b>Tools</b> &gt; <b>Options</b> &gt; <b>Devices</b> &gt; <b>Android</b>.<p class="centerAlign"><img src="images/qtcreator-options-android1.png" alt="&quot;Android options&quot;" /></p></li>
<li>In the <b>JDK location</b> field, add the path to the JDK.<p>Select the <img src="images/download-icon.png" alt="" /> (<b>Download</b>) button to go to the site where you can download the JDK. Qt Creator checks the JDK installation and reports errors.</p>
</li>
<li>In the <b>Android Settings</b> group, add paths to the Android NDK and SDK.<p>Select <img src="images/download-icon.png" alt="" /> to go to the sites where you can download the Android NDK and SDK.</p>
<p>The SDK Manager checks the Android NDK and SDK installations, reports errors, and offers to install the necessary packages.</p>
<p class="centerAlign"><img src="images/qtcreator-options-android2.png" alt="&quot;Android NDK and SDK checks&quot;" /></p><p>For more information, see <a href="creator-developing-android.html#managing-android-sdk-packages">Managing Android SDK Packages</a>.</p>
</li>
<li>Select the <b>Automatically create kits for Android tool chains</b> check box to allow Qt Creator to create the kits for you. Qt Creator displays a warning if it cannot find a suitable Qt version.</li>
<li>Select <b>File</b> &gt; <b>New File or Project</b> &gt; <b>Application</b> &gt; <b>Qt Quick Application</b> &gt; <b>Choose</b>, and follow the instructions of the wizard to create a project. For more information, see <a href="quick-projects.html">Creating Qt Quick Projects</a>.</li>
<li>To specify settings for deploying applications to Android, select <b>Projects</b> &gt; <b>Run</b> for the <b>Android</b> kit, and then select <b>Details</b> to view the <b>Deploy configurations</b>. For more information about the options you have, see <a href="creator-deploying-android.html">Deploying Applications to Android Devices</a>.</li>
<li>Enable debugging on your Android device.<p>Debugging is enabled in different ways on different Android devices. Look for <b>USB Debugging</b> under <b>Developer Options</b>. On some devices <b>Developer Options</b> is hidden and becomes visible when you tap the <b>Build number</b> field in <b>Settings</b> &gt; <b>About</b> several times.</p>
</li>
<li>Connect the Android device to the development PC with a USB cable. You might be asked to select a device in the <b>Select Android Devices</b> dialog.</li>
</ol>
<a name="managing-android-sdk-packages"></a>
<h3 id="managing-android-sdk-packages">Managing Android SDK Packages</h3>
<p>Since Android SDK Tools version 25.3&#x2e;0, only a command-line tool, <a href="https://developer.android.com/studio/command-line/sdkmanager.html">sdkmanager</a>, is provided by Android for SDK package management. To make SDK management easier, Qt Creator provides an SDK Manager for installing, updating, and removing SDK packages. You can still use sdkmanager for advanced SDK management.</p>
<p>When you add paths to the Anroid NDK and SDK in the device options, the SDK Manager checks that all the necessary SDK packages have been installed. If packages are missing or updates are needed, the SDK Manager offers to add and remove packages, as necessary. Before taking action, it prompts you to accept the changes it is about to make. In addition, it prompts you to accept Google licenses, as necessary.</p>
<p>To view the installed Android SDK packages, select <b>Tools</b> &gt; <b>Options</b> &gt; <b>Devices</b> &gt; <b>Android</b> &gt; <b>SDK Manager</b>.</p>
<p class="centerAlign"><img src="images/qtcreator-android-sdk-manager.png" alt="&quot;Android SDK Manager&quot;" /></p><p>To filter the packages, select <b>Available</b>, <b>Installed</b>, or <b>All</b> in <b>Show Packages</b>.</p>
<p>To update the installed Android SDK packages, select <b>Update Installed</b>. Select the packages to update, and then select <b>Apply</b>.</p>
<p>To specify advanced sdkmanager settings, select <b>Advanced Options</b> and enter arguments in the <b>SDK Manager arguments</b> field. The available arguments are listed and described in <b>Available arguments</b>.</p>
<p>To manage packages installed from Android SDK Tools version 25.2&#x2e;5, or earlier, you can use the native Android SDK Manager. The Qt Creator SDK Manager and the native SDK Manager are mutually exclusive, because they are used for different Android SDK Tools versions. If you have the native SDK Manager installed, you can open it by selecting <b>Native SDK Manager</b>.</p>
<a name="selecting-android-devices"></a>
<h2 id="selecting-android-devices">Selecting Android Devices</h2>
<p>When you deploy an application to an Android device with Android version 4.2 or later, the <b>Select Android Devices</b> dialog opens. It lists the devices that are connected to the development PC. and their status. You can select devices from the <b>Compatible Devices</b> list for deployment.</p>
<p>If Qt Creator determines that a device is not ready for deployment, it places the device in the <b>Incompatible Devices</b> list, with information about the issue. For example, you might need to authorize the connection on the device. After you authorize the connection on the device, select <b>Refresh Device List</b>. The device is moved to the <b>Compatible Devices</b> list and you can select it for deployment.</p>
<p>Other reasons for placing a device on the <b>Incompatible Devices</b> are that the Android version on the device is too old or that the tool chain used for building does not match the Android architecture on the device (for example, you cannot deploy an ARM build on an x86 device).</p>
<p class="centerAlign"><img src="images/qtcreator-android-select-devices.png" alt="&quot;Select Android Devices dialog&quot;" /></p><p>AVDs are also listed. To create new AVDs, select <b>Create Android Virtual Device</b>.</p>
<p>To set a device as the default device for a particular Android architecture, select the <b>Always use this device for architecture</b> check box. The <b>Select Android Devices</b> dialog will not appear until you switch to another project or restart Qt Creator.</p>
<a name="using-the-android-emulator"></a>
<h2 id="using-the-android-emulator">Using the Android Emulator</h2>
<p>To run your application on the Android Emulator, you must create Android virtual devices (AVD). Select <b>Tools</b> &gt; <b>Options</b> &gt; <b>Devices</b> &gt; <b>Android</b> &gt; <b>Add</b>. If you run an application without a device connected to the development PC and without an AVD specified, Qt Creator asks you to add an AVD.</p>
<p>To manage AVDs, select <b>Start AVD Manager</b>.</p>
<p><b>Note: </b>The Android Emulator has a bug that prevents it from starting on some systems. If the Android Emulator does not start, you can try starting it manually by running the <code>emulator-arm</code> command from the command line.</p><a name="debugging-on-android-devices"></a>
<h2 id="debugging-on-android-devices">Debugging on Android Devices</h2>
<p>Select a <a href="creator-glossary.html#glossary-build-config">debug build configuration</a> to build the application for debugging.</p>
<p><b>Note: </b>Qt Creator cannot debug applications on Android devices if Android Studio is running. If the following message is displayed in the <b>Output</b> pane, close Android Studio and try again: <i>Ignoring second debugger - accepting and dropping.</i></p></div>
<!-- @@@creator-developing-android.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="creator-connecting-mobile.html">Connecting Devices</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="creator-developing-baremetal.html">Connecting Bare Metal Devices</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
